"""
产品价格服务层
"""
from typing import List, Union
from sqlalchemy.ext.asyncio import AsyncSession

from module_product.dao.bg_product_price_dao import BgProductPriceDao
from module_product.entity.do.bg_product_price_do import BgProductPrice
from module_product.entity.vo.bg_product_price_vo import BgProductPricePageModel, BgProductPriceModel
from utils.page_util import PageResponseModel


class BgProductPriceService:
    """产品价格服务"""

    @classmethod
    async def get_bg_product_price_list(cls, query_db: AsyncSession,
                                      query_object: BgProductPricePageModel,
                                      data_scope_sql: str = None,
                                      is_page: bool = True) -> Union[List, PageResponseModel]:
        """
        获取产品价格列表
        """
        bg_product_price_list = await BgProductPriceDao.get_bg_product_price_list(
            query_db, query_object, data_scope_sql, is_page
        )
        return bg_product_price_list

    @classmethod
    async def get_bg_product_price_detail(cls, query_db: AsyncSession, bg_product_price_id: int) -> BgProductPrice:
        """
        获取产品价格详情
        """
        bg_product_price = await BgProductPriceDao.get_bg_product_price_detail(query_db, bg_product_price_id)
        return bg_product_price

    @classmethod
    async def get_bg_product_prices_by_product_id(cls, query_db: AsyncSession, product_id: int) -> List[BgProductPrice]:
        """
        根据产品ID获取所有价格
        """
        prices = await BgProductPriceDao.get_bg_product_prices_by_product_id(query_db, product_id)
        return prices

    @classmethod
    async def add_bg_product_price(cls, query_db: AsyncSession, bg_product_price: BgProductPriceModel) -> BgProductPrice:
        """
        添加产品价格
        """
        bg_product_price = await BgProductPriceDao.add_bg_product_price(query_db, bg_product_price)
        return bg_product_price

    @classmethod
    async def edit_bg_product_price(cls, query_db: AsyncSession, bg_product_price: BgProductPriceModel) -> None:
        """
        编辑产品价格
        """
        await BgProductPriceDao.edit_bg_product_price(query_db, bg_product_price)

    @classmethod
    async def delete_bg_product_price(cls, query_db: AsyncSession, bg_product_price_id: int) -> int:
        """
        删除产品价格
        """
        result = await BgProductPriceDao.delete_bg_product_price(query_db, bg_product_price_id)
        return result
